Ext.define('Projeto.store.Users', {
	extend: 'Ext.data.Store',
	requires: 'Projeto.model.User',
	model: 'Projeto.model.User',
	
	proxy: {
		type: 'ajax',
		method: 'post',
		api: {
			create: 'usuarios/save',
			read: 'usuarios/findAll',
			update: 'usuarios/save',
			destroy: 'usuarios/delete'
		},
		
		reader: {
			type: 'json',
			root: 'result',
			successProperty: 'success'
		},
		
		writer: {
            type: 'json',
            writeAllFields: true,
            encode: true,
            root: 'data',
        	successProperty: 'success'
        },
		
		listeners: {
			exception: function(proxy, response, operation) {
				Ext.MessageBox.show({
					title: 'Ocorreu um erro!',
					msg: 'operation.getError()',
					icon: Ext.MessageBox.ERROR,
					buttons: Ext.Msg.OK
				})
			}
		}
	},
	
	listeners: {
        write: function(proxy, operation){
            //alert('ok');
        }
    },
	
	autoLoad: false
});